//toString 返回一个对象的字符串描述信息
let obj = {};
console.log(obj.toString());//[object Object]
//很多内置对象都会重写toString方法，使其返回一个更有意义的字符串
let myDate = new Date();
console.log(myDate.toString());//Fri May 26 2023 12:07:48 GMT+0800 (中国标准时间)
let myArray = ['a','b','c'];
console.log(myArray.toString());;//a,b,c
console.log(Array.prototype.toString=== Object.prototype.toString)
console.log(Object.prototype.toString.call(myArray));//[object Array]

//toLocaleString  local locale 转成字符串的时候应该考虑当前的时区
let myDate2 = new Date();
console.log(myDate2.toString())
console.log(myDate2.toLocaleString())

let myNumber = 123456.789;
console.log(myNumber.toString())
console.log(myNumber.toLocaleString())

let myPerson = {
    firstName:'zhang',
    lastName:'san',
    toString(){
        return this.lastName+' '+this.firstName;
    },
    toLocaleString(){
        return this.firstName+' '+this.lastName;
    }
}
console.log(myPerson.toString())
console.log(myPerson.toLocaleString())